import java.util.Random;
import java.util.Scanner;

public class demo1 {
    public static void main(String[] args) {
        int[] arry = createNumber();
        for (int i = 0; i < arry.length; i++) {
            System.out.print(arry[i] + " ");
        }

        int[] userInputArr = userInputNumber();

        int redCount = 0;
        int blueCount = 0;

        for (int i = 0; i < userInputArr.length - 1; i++) {
            int redNumber = userInputArr[i];
            for (int j = 0; j < arry.length - 1; j++) {
                if (arry[j] == redNumber) {
                    redCount++;
                    break;
                }
            }
        }

        int blueNumber = userInputArr[userInputArr.length - 1];
        if (blueNumber == arry[arry.length - 1]) {
            blueCount++;
        }
        System.out.println("红球：" + redCount);
        System.out.println("蓝球：" + blueCount);

        if (redCount == 6 && blueCount == 1) {
            System.out.println("恭喜你，中了1000万");
        } else if (redCount == 6 && blueCount == 0) {
            System.out.println("恭喜你，中了500万");
        } else if ((redCount == 5 && blueCount == 0) || (redCount == 4 && blueCount == 1)) {
            System.out.println("恭喜你，中了200万");
        } else if ((redCount == 4 && blueCount == 0) || (redCount == 3 && blueCount == 1)) {
            System.out.println("恭喜你，中了100万");
        } else if ((redCount == 3 && blueCount == 0) || (redCount == 2 && blueCount == 1)) {
            System.out.println("恭喜你，中了10万");
        } else if ((redCount == 2 && blueCount == 0) || (redCount == 1 && blueCount == 1)) {
            System.out.println("恭喜你，中了1万");
        } else if ((redCount == 1 && blueCount == 0) || (redCount == 0 && blueCount == 1)){
            System.out.println("恭喜你，中了500");
        }else {
            System.out.println("谢谢惠顾！！！");
        }
    }

    public static int[] userInputNumber() {
        int[] arry = new int[7];

        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arry.length - 1; ) {
            System.out.print("请输入第" + (i + 1) + "个红球号码：");
            int redNumber = sc.nextInt();
            if (redNumber >= 1 && redNumber <= 33) {
                boolean flag = contain(arry, redNumber);
                if (!flag) {
                    arry[i] = redNumber;
                    i++;
                } else {
                    System.out.println("当前红球号码已经存在，请重新输入！！！");
                }
            } else {
                System.out.println("当前红球号码超出范围，请从新输入！！！");
            }
        }

        while (true) {
            System.out.print("请输入蓝球号码：");
            int blueNumber = sc.nextInt();
            if (blueNumber >= 1 && blueNumber <= 16) {
                arry[arry.length - 1] = blueNumber;
                break;
            } else {
                System.out.println("当前号码超出范围,请重新输入！！！");
            }
        }
        return arry;
    }

    public static int[] createNumber() {
        int[] arry = new int[7];

        Random r = new Random();
        for (int i = 0; i < arry.length - 1; ) {
            int readNumber = r.nextInt(33) + 1;
            boolean flag = contain(arry, readNumber);
            if (!flag) {
                arry[i] = readNumber;
                i++;
            }
        }

        int blueNumber = r.nextInt(16) + 1;
        arry[arry.length - 1] = blueNumber;

        return arry;
    }

    public static boolean contain(int[] arry, int number) {
        for (int i = 0; i < arry.length; i++) {
            if (arry[i] == number) {
                return true;
            }
        }
        return false;
    }
}
